package com.leo.train.business.controller;

import com.leo.train.common.resp.CommonResp;
import com.leo.train.common.resp.EnumInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/enum")
@Slf4j
public class EnumController {
    @Autowired
    private com.leo.train.business.service.EnumService enumService;

    /**
     * 根据枚举code获取枚举列表
     * @param code 枚举code
     * @return
     */
    @GetMapping("/list")
    public CommonResp<List<EnumInfoDto>> typeEnums(@RequestParam String code){
        log.info("获取枚举列表: {}", code);
        return new CommonResp<>(enumService.getEnumListByCode(code));
    }
}
